/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jdbcfox;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.andesconsulting.dbf.DbfFile;

/**
 *
 * @author avbravo
 */
public class Leerdbf {
    public void leer(String ruta) throws IOException{
         try {
            DbfFile bfile;
                  //bfile = new DbfFile("/home/avbravo/Monica85/emp_1011/empresas.dbf");
                   bfile = new DbfFile(ruta);
                  bfile.open();
                 System.out.println(" contador " + bfile.getCount());

                  for (int i = 0; i <= bfile.getCount(); i++) {

                      bfile.go(i);
                      Map<String, String> map = bfile.scatter();
                      Iterator it = map.keySet().iterator();
                      System.out.println("=============================================================");
                      while (it.hasNext()) {
                          // Get Clave 
                          String clave = (String) it.next();
                          String valor = map.get(clave);
      //                    System.out.println(clave+ " --> "+valor);
                          switch(clave){
                              case "COD_EMPRE":
                                  System.out.println("codigo  "+valor);
                                  break;
                              case "NAME_EMPRE":
                                   System.out.println("nombre  "+valor);
                                  break;
                              case "DIRECC1":
                                   System.out.println("direccion  "+valor);
                                  break;
                                  case "CONTACTO":
                                   System.out.println("contacto  "+valor);
                                  break;
                                 
                          }
                  

                      }
                  }
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Jdbcfox.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
